using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using Dimok;
using Dimok.Concurrency;

////////////////////////////////////////////////////////////////////////////////////////////////////
// namespace: Dimok.Concurrency
//
// summary:	.
////////////////////////////////////////////////////////////////////////////////////////////////////

namespace Dimok.Concurrency
{
	/// <summary>
	/// Summary description for CacheManager.
	/// </summary>
	public class CacheManager : Page
	{
		protected System.Web.UI.HtmlControls.HtmlGenericControl pre;

		////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>	Event handler. Called by Page for load events. </summary>
		///
		/// <remarks>	Dimon, 11/24/2010. </remarks>
		///
		/// <param name="sender">	Source of the event. </param>
		/// <param name="e">			Event information. </param>
		////////////////////////////////////////////////////////////////////////////////////////////////////

		private void Page_Load(object sender, System.EventArgs e){
			bool clearCache = Request["clear"] != null && Request["clear"] != "";
			ArrayList al = new ArrayList();
			ArrayList alKeys = new ArrayList();
			IDictionaryEnumerator denum = (IDictionaryEnumerator)Context.Cache.GetEnumerator();
			while(denum.MoveNext())
				try{
					al.Add("<TABLE><TR valign='top'><TD>"+denum.Key+"</TD><TD>"+((ConcurrencyTag)denum.Value).ToString()+"</TD></TR></TABLE>");
					alKeys.Add(denum.Key);
				}catch(Exception){}
			//foreach( string key in alKeys )
			//		Context.Cache.Remove(key);
			pre.InnerHtml = string.Join("<BR>",(string[])al.ToArray(typeof(string)));
		}

		#region Web Form Designer generated code

		////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>	Raises the initialise event. </summary>
		///
		/// <remarks>	Dimon, 11/24/2010. </remarks>
		///
		/// <param name="e">	Event information to send to registered event handlers. </param>
		////////////////////////////////////////////////////////////////////////////////////////////////////

		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}

		////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>	
		/// Required method for Designer support - do not modify the contents of this method with the code
		/// editor. 
		/// </summary>
		///
		/// <remarks>	Dimon, 11/24/2010. </remarks>
		////////////////////////////////////////////////////////////////////////////////////////////////////

		private void InitializeComponent()
		{    
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion
	}
}
